Skip to content

feat: add microfrontend template generator command#943

Open
aman06it wants to merge 2 commits into
salesforcecli:mainfrom
aman06it:feat/microfrontend-template
Open

feat: add microfrontend template generator command#943
aman06it wants to merge 2 commits into
salesforcecli:mainfrom
aman06it:feat/microfrontend-template

Conversation

@aman06it
Copy link
Copy Markdown

@aman06it aman06it commented May 22, 2026

Summary

  • Adds sf template generate lightning embedding to scaffold a Lightning Web Component bundle that wraps <lightning-embedding>.
  • Command is added under the existing lightning topic as a peer of app, component, event, interface, test (per team alignment in #plugin-design-templates — avoids both mfe and microfrontend).
  • Flags: --name, --src, --sandbox (multi-value, validated against W3C sandbox tokens), --shell-title, --output-dir, --api-version, --internal.
  • --src validation: https only; plain http allowed only for localhost / 127.0.0.1 (local dev).
  • Command is hidden via static hidden = true until rollout is finalized.
  • Naming and flag conventions audited against the topics and flags developer guides.
  • Depends on the new LightningEmbeddingGenerator in feat: add microfrontend template generator forcedotcom/salesforcedx-templates#821.

@aman06it aman06it requested a review from a team as a code owner May 22, 2026 10:25
@salesforce-cla
Copy link
Copy Markdown

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Aman Singh <a***@A***.i***.s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated.

Exposes `sf template generate microfrontend` to scaffold a microfrontend
LWC bundle, paired with the new generator in salesforcedx-templates.
@aman06it aman06it force-pushed the feat/microfrontend-template branch from 3028578 to 0efa415 Compare May 22, 2026 10:39
@aman06it
Copy link
Copy Markdown
Author

@salesforce-cla check

Per team alignment in #plugin-design-templates, rename the command to
align with the <lightning-embedding> base component name.

- Command: sf template generate microfrontend → sf template generate lightning embedding
- Move src/commands/template/generate/microfrontend.ts under
  lightning/ as a peer of app, component, event, interface, test
- messages/microfrontend.md → messages/lightningEmbedding.md
- Class Microfrontend → LightningEmbedding
- Imports updated: MicrofrontendOptions → LightningEmbeddingOptions,
  TemplateType.Microfrontend → TemplateType.LightningEmbedding
@aman06it aman06it force-pushed the feat/microfrontend-template branch from c4b860a to d72b7f5 Compare May 27, 2026 16:40
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningEmbedding');

// Keep in-sync with VALID_SANDBOX_TOKENS in salesforcedx-templates/src/generators/lightningEmbeddingGenerator.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not export these from the library?

description: messages.getMessage('flags.name.description'),
required: true,
}),
src: Flags.string({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use Flags.url here instead? If not, consider adding a parse method to validate this input

componentname: flags.name,
src: flags.src,
sandbox: flags.sandbox.join(' '),
shellTitle: flags['shell-title'] ?? flags.name,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If --shell-title is for screen reader accessibility, a PascalCase fallback is less than ideal. Just make --shell-title required and don't have a fallback.

@iowillhoit
Copy link
Copy Markdown
Contributor

Please add tests for these templates. Lots of examples in tests/

Copy link
Copy Markdown
Contributor

@iowillhoit iowillhoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants